using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 大嘴巴夹子
/// </summary>
public class jiazi : MonoBehaviour
{
    public float damage = -10;
    private bool isInArea = false;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Player"&& GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).IsName("idle"))
        {
            GetComponent<Animator>().Play(Animator.StringToHash("eat"));
            
            
        }
        else if(collision.gameObject.tag == "Player")
        {
           
            collision.gameObject.GetComponent<playerControl>().hit(collision.gameObject, damage);

        }
    }

    public void OnTriggerStay2D(Collider2D collision)
    {
        
    }

    public void Damage()
    {
        Debug.Log("eat damage");
        isInArea = true;
       // collision.gameObject.GetComponent<state>().health += damage;
    }
}
